package gui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class OpenExistingProject {

	protected Shell shlOpenExistingProject;
	private Text text;

	/**
	 * Launch the application.
	 * @param args
	 */
	// just for testing
//	public static void main(String[] args) {
//		try {
//		//	OpenExistingProject window = new OpenExistingProject();
//		//	window.open();
//			GUIManager.getDefault().openexist.open();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shlOpenExistingProject.open();
		shlOpenExistingProject.layout();
		while (!shlOpenExistingProject.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shlOpenExistingProject = new Shell();
		shlOpenExistingProject.setSize(410, 162);
		shlOpenExistingProject.setText("Open Existing Project");
		
		Label lblNewLabel = new Label(shlOpenExistingProject, SWT.NONE);
		lblNewLabel.setBounds(10, 43, 55, 21);
		lblNewLabel.setText("File Path");
		
		text = new Text(shlOpenExistingProject, SWT.BORDER);
		text.setBounds(71, 40, 207, 21);
		
		Button btnBrowse = new Button(shlOpenExistingProject, SWT.NONE);
		btnBrowse.setBounds(298, 38, 75, 25);
		btnBrowse.setText("Browse");
		
		Button btnOk = new Button(shlOpenExistingProject, SWT.NONE);
		btnOk.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shlOpenExistingProject.dispose();
			}
		});
		btnOk.setBounds(92, 89, 75, 25);
		btnOk.setText("Ok");
		
		Button btnCancel = new Button(shlOpenExistingProject, SWT.NONE);
		btnCancel.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				shlOpenExistingProject.dispose();
			}
		});
		btnCancel.setBounds(190, 89, 75, 25);
		btnCancel.setText("Cancel");

	}

}
